home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / admin / newinfo-.000 / newinfo- / newinfo < prev    next >
Text File  |  1995-05-13  |  6KB  |  255 lines

  1. #!/bin/bash
  2. #       Matt's Newinfo System Shell.  14/05/95.
  3. #
  4. #       Matt's Newinfo System V1.1
  5. #
  6. #       Copyright (C) Matt Bottrell, 1995.  All rights reserved.
  7. #
  8. #-----------------------------------------------------------------------------    
  9. #    IMPORTANT! :
  10. #   Edited areas are listed as %% text to edit %%   Read the comment above to 
  11. #   find out what the area is specifically for.  In this state it creates a
  12. #   nice information system that allows the admin user to create update files
  13. #   per month.  This can easily be edited to create a user login screen.
  14. #
  15. #   The next version will include termcap support for ESC, Crtl-C, Crtl-Z etc,
  16. #   making the system more stable.
  17. #
  18. #    Please note, the only restriction on the sytem is that the initial loading
  19. #    screen is left in-tact.
  20. # ------------------------------------------------------------------------------
  21.  
  22. #
  23. #
  24. PATH=/bin:/usr/bin:/etc:/usr/5bin:/usr/ucb
  25.  
  26. # Setup pretty stuff
  27. kl=`tput kcub1`
  28. mb=`tput blink`
  29. so=`tput smso`
  30. md=`tput bold`
  31. us=`tput smul`
  32. dl=`tput dl`
  33. me=`tput sgr0`
  34. cl=`tput clear`
  35.  
  36. # Counter Input from user
  37. tnum=0  
  38. DATE=`date| awk '{printf ("%s %s %s, %s ", $1, $3, $2, $6)}'`
  39. TIME=`date +%H:%M`
  40. PERSON=`whoami`
  41. MACHINE=`sed -n '1p' /etc/HOSTNAME`
  42. #
  43. # Function definitions!
  44. #
  45. # Prompt for yes or no answer - returns non-zero for no
  46. getyn() {
  47.     while   echo "\n$* (y/n)$mb?$me \c">&2
  48.     do      read yn rest
  49.         case $yn in
  50.         [yY])   return 0
  51.             ;;
  52.         [nN])   return 1
  53.             ;;
  54.         *)      echo "Please answer y or n" >&2
  55.             ;;
  56.         esac
  57.     done
  58. }
  59.  
  60. # function to read in the requested file.
  61. read_news() {
  62.     clear
  63.     echo $btype
  64.     echo " "
  65.     sleep 2
  66.     less -M -e $FILEREAD
  67. }
  68.  
  69. # exit and clean up after yourself
  70. bye_bye() {
  71.     rm -f /tmp/$$*
  72.     clear
  73.     echo "$me $md Exiting the %% Enter the menu system name here %%...."
  74.     echo " "
  75.     echo "  Hope you enjoyed your stay, $PERSON!$me"
  76.     exit $*
  77. }
  78.  
  79.  
  80. # Prompt with mesg, return non-zero on q
  81. prompt() {
  82.     clear
  83.     while   clear;echo -n "${mesg}$so " >&2
  84.         
  85.     do      read cmd
  86.         case $cmd in
  87.         +x|-x)  set $cmd                                        ;;
  88.         Q|q)    echo " "; return 1                         ;;
  89. #               !*)     eval `expr "$cmd" : "!\(.*\)"`                  ;;
  90.         "")     # If there is an argument use it as the default
  91.             # else loop until 'cmd' is set
  92.             [ "$1" ] && {
  93.                 cmd=$1
  94.                 return 0
  95.             }
  96.             : continue
  97.             ;;
  98.         *)      return 0                                        ;;
  99.         esac
  100.     done
  101. }
  102.  
  103. # Print an error message
  104. error() {
  105.     echo "\nError: $*" >&2
  106.     return 1
  107. }
  108.  
  109.  
  110. # Start of actual command.
  111. # First change to the correct directory in which the text files are located in.
  112.  
  113. cd /usr/doc/newinfo
  114. clear
  115.  
  116. # Initial message to be displayed on startup of newinfo.
  117.  
  118. echo "Welcome to the %% Enter the name of the menu here.%% "
  119. echo " "
  120.  
  121. # These 3 lines are required by the licencse agreement.  This is all I request 
  122. # not to be modified.
  123.  
  124. echo "Created under NewInfo Version 1.1."
  125. echo "(C) Matt E. Bottrell, 1995.  All Rights Reserved."  
  126. echo "Email meb@deakin.edu.au for details."
  127. echo " " ; echo " " ; echo " "
  128. echo -n "Loading.  Please wait."
  129. sleep 1        
  130. echo -n "."        # Not the nicest way, but needed for portability.
  131. sleep 1
  132. echo -n "."
  133. sleep 1
  134. echo -n "."
  135. sleep 1
  136. echo -n "."
  137.  
  138. # Display the menu system.
  139.  
  140. clear
  141. mesg="$so$TIME             Madhouse Information System               $DATE $me 
  142.                $md$MACHINE$me                                    
  143. -------------------------------------------------------------------------------
  144.  
  145.                $md SYSTEM NEWS.$me
  146.            
  147.    $so 1.$me January.        $so 2.$me February.        $so 3.$me March.
  148.    $so 4.$me April.        $so 5.$me May.        $so 6.$me June.
  149.    $so 7.$me July.        $so 8.$me August.        $so 9.$me September.
  150.   $so 10.$me October.           $so 11.$me November.          $so 12.$me December.
  151.  
  152.                $md GENERAL NEWS.$me
  153.  
  154.   $so 50.$me General Info.   $so 51.$me Of Interest.       $so 52.$me Email Info.
  155.   $so 53.$me Today's Message.$so 54.$me IRC Tutorial.      
  156.  
  157.                $md EMAIL SUPPORT.$me
  158.  
  159.   $so 60.$me Email Author.    $so 61.$me Email Help Desk.   $so 62.$me Email Root.
  160.  
  161. -------------------------------------------------------------------------------
  162. Select an option and press ENTER (or q to quit):$so $me"
  163. while :
  164. do prompt || bye_bye
  165.     case $cmd in
  166.     1)      echo $me        
  167.         btype="January News Articles. . . ."
  168.         FILEREAD="jan"
  169.         read_news
  170.         ;;
  171.  
  172.     2)      echo $me        
  173.         btype="February News Articles. . . ."
  174.         FILEREAD="feb"
  175.         read_news
  176.         ;;
  177.  
  178.     3)      echo $me        
  179.         btype="March News Articles. . . ."
  180.         FILEREAD="mar"
  181.         read_news
  182.         ;;
  183.  
  184.     4)      echo $me        
  185.         btype="April News Articles. . . ."
  186.         FILEREAD="apr"
  187.         read_news
  188.         ;;
  189.  
  190.     5)      echo $me        
  191.         btype="May News Articles. . . ."
  192.         FILEREAD="may"
  193.         read_news
  194.         ;;
  195.     
  196.     50)      echo $me        
  197.         btype="General Madhouse News. . . ."
  198.         FILEREAD="general"
  199.         read_news
  200.         ;;
  201.  
  202.     51)      echo $me        
  203.         btype="Things Of Interest. . . ."
  204.         FILEREAD="interest"
  205.         read_news
  206.         ;;
  207.  
  208.     52)      echo $me        
  209.         btype="Email Support Information. . . ."
  210.         FILEREAD="email"
  211.         read_news
  212.         ;;
  213.  
  214.     53)      echo $me        
  215.         btype="Message of the day. . . ."
  216.         FILEREAD="/etc/motd"
  217.         read_news
  218.         ;;
  219.  
  220.     54)      echo $me        
  221.         btype="Background of Madhouse IRC. . . ."
  222.         FILEREAD="irc"
  223.         read_news
  224.         ;;
  225.  
  226.     60)      echo $me        
  227.         clear
  228.         echo "Email the Author of New-Info. . . ."
  229.         sleep 3
  230.         pine meb@deakin.edu.au
  231.         ;;
  232.  
  233.     61)      echo $me        
  234.         clear
  235.         echo "Email the Help Desk. . . ."
  236.         sleep 3
  237.         pine problems
  238.         ;;
  239.  
  240.     62)      echo $me        
  241.         clear
  242.         echo "Email the Operator. . . ."
  243.         sleep 3
  244.         pine root
  245.         ;;
  246.  
  247.     *)      echo $me        
  248.         echo "Enter either 1 - 5, 50 - 54, 60 - 62  or q to quit"
  249.         sleep 5
  250.         ;;
  251.     esac
  252. done
  253.  
  254. bye_bye
  255.